package com.threefish.modules.sys.entity.datatable;

import com.threefish.common.entity.AbstractBaseEntity;
import com.threefish.modules.sys.enums.TableType;
import org.nutz.dao.entity.annotation.*;
import org.nutz.plugins.validation.annotation.Validations;

import java.util.List;

/**
 * @author 黄川 306955302@qq.com
 * @date: 2018/6/5
 * 描述此类：
 */
@Table("sys_data_table")
@Comment("表定义信息")
@TableIndexes({@Index(name = "realName_unique", fields = {"tableName"}), @Index(name = "name_unique", fields = {"name"})})
public class DataTable extends AbstractBaseEntity {

    @Id
    private int id;

    @Column
    @Comment("表名")
    @ColDefine(notNull = true, width = 50)
    @Validations(required = true, strLen = {2, 50}, errorMsg = "表名称必须填写,长度2-50")
    private String name;

    @Column
    @Comment("物理表名")
    @ColDefine(width = 50)
    private String tableName;

    @Column
    @Comment("备注")
    @ColDefine(notNull = true, width = 50)
    @Validations(required = true, strLen = {2, 50}, errorMsg = "表备注必须填写,长度2-50")
    private String comment;

    /**
     * @see TableType
     */
    @Column
    @Comment("表类型")
    @Validations(required = true, el = "value>=0", errorMsg = "表类型必须填写")
    private int tableType;


    @Column
    @Comment("是否系统表")
    @Default("0")
    private boolean system;

    @Column(version = true)
    @Comment("版本")
    private int version;

    @Column
    @Comment("状态 0未同步 1已同步 2同步失败")
    private int status;

    @Column
    @Comment("表单模版")
    @Default("1")
    private int formTemplate;

    /**
     * 一对多关系
     */
    @Many(field = "tableId")
    private List<TableFields> fields;

    public int getFormTemplate() {
        return formTemplate;
    }

    public void setFormTemplate(int formTemplate) {
        this.formTemplate = formTemplate;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public boolean isSystem() {
        return system;
    }

    public void setSystem(boolean system) {
        this.system = system;
    }

    public int getVersion() {
        return version;
    }

    public void setVersion(int version) {
        this.version = version;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public int getTableType() {
        return tableType;
    }

    public void setTableType(int tableType) {
        this.tableType = tableType;
    }

    public List<TableFields> getFields() {
        return fields;
    }

    public void setFields(List<TableFields> fields) {
        this.fields = fields;
    }
}
